package com.shawn.model.vo;

import com.shawn.commons.utils.RC;
import com.shawn.model.entity.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnnouncementVo {
    private String id;
    private String title;
    private String description;
    private String createDate;

    public static AnnouncementVo init(Announcement announcement){
        AnnouncementVo vo = new AnnouncementVo();
        vo.setId(String.valueOf(announcement.getId()));
        vo.setTitle(announcement.getTitle());
        vo.setDescription(announcement.getDescription());
        Date created = announcement.getCreated();
        SimpleDateFormat dateFormat = new SimpleDateFormat(RC.ANNOUNCEMENT_DATE_FORMAT);
        vo.setCreateDate(dateFormat.format(created));
        return vo;
    }
}
